package com.broad.data.storage.server.service.impl;

import com.broad.data.storage.common.model.UserInfo;
import com.broad.data.storage.mybatis.dao.mapper.UserInfoMapper;
import com.broad.data.storage.server.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService implements IUserService {

    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public void addUser(UserInfo userInfo) {
        //todo: add user-token
        userInfoMapper.addUser(userInfo);
    }

    @Override
    public void updateUser(String uid, String password, String detail) {
        userInfoMapper.updateUser(uid, password, detail);
    }

    @Override
    public void deleteUser(String uid) {
        userInfoMapper.deleteUser(uid);
    }

    @Override
    public UserInfo getUserInfoById(String uid) {
        return userInfoMapper.getUserInfoSelective(uid);
    }

    @Override
    public boolean checkUserNameAndPassword(String username, String password) {
        UserInfo info = userInfoMapper.selectByUserNameAndPassword(username, password);
        return info != null;
    }
}
